package in.muton.edushare.newentities.upgraded;

import in.muton.edushare.newentities.upgraded.multipleInvite.MultipleAudienceInvite;
import in.muton.edushare.newentities.upgraded.multipleInvite.PollMultipleInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.BatchInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.CourseInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.DeptInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.GroupInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.SingleAudienceInvite;
import in.muton.edushare.newentities.upgraded.singleInvite.UnivInvite;
import in.muton.edushare.wicket.models.CayenneModel;

import java.util.HashMap;

import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Batches;
import com.edushare.common.vo.CourseInstances;
import com.edushare.common.vo.Departments;
import com.edushare.common.vo.Groups;
import com.edushare.common.vo.Poll;
import com.edushare.common.vo.Universities;

public class InviteFactory {
	public static SingleAudienceInvite getInviteClass(IModel<?> model) {
		if (model.getObject() instanceof Universities) {
			return new UnivInvite(new CayenneModel<Universities>(
					(Universities) model.getObject()));
		} else if (model.getObject() instanceof Departments) {
			return new DeptInvite(new CayenneModel<Departments>(
					(Departments) model.getObject()));
		} else if (model.getObject() instanceof CourseInstances) {
			return new CourseInvite(new CayenneModel<CourseInstances>(
					(CourseInstances) model.getObject()));
		} else if (model.getObject() instanceof Groups) {
			return new GroupInvite(new CayenneModel<Groups>((Groups) model
					.getObject()));
		} else if (model.getObject() instanceof Batches) {
			return new BatchInvite(new CayenneModel<Batches>((Batches) model
					.getObject()));
		} else
			return null;
	}

	public static HashMap<String, Integer> getRoles(IModel<?> model) {
		return RoleManagement.getRoles(model);
	}

	public static MultipleAudienceInvite getMultipleAudienceInvite(
			IModel<?> model) {
		if (model.getObject() instanceof Poll) {
			Poll p = (Poll) model.getObject();
			return new PollMultipleInvite(new CayenneModel<Poll>(p));
		}
		return null;
	}

}
